package com.coder4j.biz.service;

import com.coder4j.biz.entity.AiWanxiangEntity;
import com.coder4j.biz.mapper.AiWanxiangMapper;
import com.coder4j.biz.vo.AiWanxiangVO;
import com.coder4j.starter.tools.enums.StatusEnums;
import com.coder4j.starter.tools.util.StringUtils;
import com.coder4j.starter.web.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;

import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

/**
 * 通义万相
 * @author keller
 * @date 2024-12-09 15:39:06
 */
@Service
@Slf4j
public class AiWanxiangService extends BaseServiceImpl<AiWanxiangMapper,AiWanxiangEntity,AiWanxiangVO> {

    @Resource
    private AiWanxiangMapper mapper;


    @Override
    public AiWanxiangVO entity2Vo(AiWanxiangEntity entity) {
        AiWanxiangVO vo = new AiWanxiangVO();
        BeanUtils.copyProperties(entity,vo);

        if(StringUtils.notEmpty(entity.getState())){
            try {
                vo.setStateStr(StatusEnums.valueOf(entity.getState()).getDescription());
            }catch (Exception e){
                log.error("----",e);
            }
        }


        return vo;
    }

    @Override
    public AiWanxiangEntity vo2Entity(AiWanxiangVO vo) {
        AiWanxiangEntity entity = new AiWanxiangEntity();
        BeanUtils.copyProperties(vo, entity);
        return entity;
    }


}
